package com.longjianghuasheng.logistics.business.news

import android.os.Bundle
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.base.BaseTitleFragment
import com.longjianghuasheng.logistics.databinding.FragmentNewsBinding
import com.longjianghuasheng.logistics.ext.loadRichText
import com.longjianghuasheng.logistics.ext.observer

class NewsFragment : BaseTitleFragment<NewsViewModel, FragmentNewsBinding>() {

    override fun layoutId(): Int = R.layout.fragment_news


    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
    }


    override fun createObserver() {
        super.createObserver()
        mViewModel.result.observer(this) {

            initTitleBar(it.title ?: "")
            mDatabind.webView.loadRichText(it.content ?: "", !(it.content?.contains("http")?:false))

        }
    }

    override fun initData() {
        super.initData()
        mViewModel.id = arguments?.getInt("id") ?: 0
    }

    override fun lazyLoadData() {
        super.lazyLoadData()
        mViewModel.news_show()
    }

}